


#include <pthread.h>
#include <stdio.h>
#include <semaphore.h>
#include <string.h>

#include "ui.h"
#include "input_manager.h"
#include "disp_manager.h"
#include "font_manager.h"




static  int Defaultdrawbutton(struct Button * pbutton,DispBuff_p pDisbuff)
{

	printf("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__);
	DrawRegion(&pbutton->tRegion, BUTTON_DEFAULT_COLOR);
	DrawTextInRegionCentral(pbutton->name, &pbutton->tRegion, BUTTON_TEXT_COLOR);
	FlushDisplayRegion(&pbutton->tRegion, *pDisbuff);

	 return 0;


}
static int Defaultchecked(struct Button * pbutton,DispBuff_p pDisbuff, inputEvent_p inputEventp)
{
	unsigned int color = BUTTON_DEFAULT_COLOR;


	pbutton->status = !pbutton->status;
	if(pbutton->status)
	{
		color = BUTTON_PRESSED_COLOR;


	}


	DrawRegion(&pbutton->tRegion, color);
		printf("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__);
	DrawTextInRegionCentral(pbutton->name, &pbutton->tRegion, BUTTON_TEXT_COLOR);
		printf("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__);
	FlushDisplayRegion(&pbutton->tRegion, *pDisbuff);


	
	return 0;


}



void InitButton(char * name, pButton pbutton, Region_p prigion, DRAWBUTTON drawbutton, CHECKED  checked)
{
	pbutton->status =0;
	pbutton->name = name;

	if(prigion != NULL)
	{
		 pbutton->tRegion = *prigion   ;
	}
	pbutton->DrawButton = drawbutton ? drawbutton : Defaultdrawbutton;
	pbutton->Checked = checked ? checked : Defaultchecked;


}


















































